package cn.com.zhbs.common.security;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

import java.util.Properties;
import cn.com.zhbs.common.util.Encrypt;

public class PropertyPlaceholderConfigurerExt extends
		PropertyPlaceholderConfigurer {
	

	@Override
	protected void processProperties(
			ConfigurableListableBeanFactory beanFactoryToProcess,
			Properties props) throws BeansException {
		
		String password = props.getProperty("jdbc.password"); 
        if (password != null) { 
                //解密jdbc.password属性值，并重新设置 
                props.setProperty("jdbc.password", Encrypt.decrypt(password)); 
        } 
        super.processProperties(beanFactoryToProcess, props); 
	}

	public static void main(String[] args) {
		System.out.println( Encrypt.encrypt("admin"));
	}
}
